<template>
  <div class="GReceiveSuspiciousList4">
    <filterPanel filterName="GReceiveSuspiciousList4Filter" filterTitle="高危人员收件查询" :filterList="filterData"
                 @filterChange="filterChange"></filterPanel>
    <tablePanel tableName="GReceiveSuspiciousList4Table" :tableLoading="loading" tableTitle="高危人员收件列表" :tableList="tableList"
                :tableData="tableData" :total="total" :currentPage="form.page_start" :pageSize="form.page_size"
                @sizeChange="sizeChange" @pageChange="pageChange" @tableClick="tableClick">
    </tablePanel>
    <zy-model title="标记人员" :show="showModel" :showBtn="false" @close="showModel = false">
      <div class="addCatalog">
        <div class="inputArea">
          <div class="inputTitle required">人员名称</div>
          <div class="inputContent">{{person_name}}</div>
        </div>
        <div class="inputArea">
          <div class="inputTitle required">标记类型</div>
          <div class="inputContent">
            <el-radio-group v-model="person_judge_level">
              <el-radio :label="item.value" v-for="item in bjList" style="margin-right: 8px">{{item.name}}</el-radio>
            </el-radio-group>
          </div>
        </div>
        <div class="btnArea">
          <zy-button class="btn" @click="showModel = false">取消</zy-button>
          <zy-button class="btn" type="primary" @click="submitBj">确定</zy-button>
        </div>
      </div>
    </zy-model>
  </div>
</template>

<script>
	import {mapGetters} from "vuex";

	export default {
		name: "GReceiveSuspiciousList4",
		props: {},
		data() {
			return {
				filterData: [
					{
						title: '收件编号',
						name: 'logistics_id',
						type: 'input',
						value: '',
						isShow: true,
						isSelected: true
					},
					{
						title: '收件单号',
						name: 'logistics_no',
						type: 'input',
						value: '',
						isShow: true,
						isSelected: true
					},
					{
						title: '承运物流企业',
						name: 'logistics_enterprise',
						type: 'input',
						value: '',
						isShow: true,
						isSelected: true
					},
					// {
					// 	title: '企业类型',
					// 	name: 'company_type',
					// 	type: 'select',
					// 	optionList: [
					// 		{label: '全部', value: ''},
					// 		{label: '物流', value: 0},
					// 		{label: '快递', value: 1},
					// 		{label: '分拣中心', value: 2},
					// 	],
					// 	value: '',
					// 	isShow: true,
					// 	isSelected: true
					// },
					// {
					// 	title: '送达站点',
					// 	name: 'arrive_region',
					// 	type: 'cascader',
					// 	value: [],
					// 	optionList: [],
					// 	optionProps: {
					// 		checkStrictly: true,
					// 		value: 'value',
					// 		label: 'label',
					// 		children: 'children'
					// 	},
					// 	isShow: true,
					// 	isSelected: true
					// },
					{
						title: '寄件人',
						name: 'sender',
						type: 'input',
						value: '',
						isShow: true,
						isSelected: true
					},
					{
						title: '寄件人联系方式',
						name: 'sender_phone',
						type: 'input',
						value: '',
						isShow: true,
						isSelected: true
					},
					// {
					// 	title: '揽件员',
					// 	name: 'employee_name',
					// 	type: 'input',
					// 	value: '',
					// 	isShow: true,
					// 	isSelected: true
					// },
					{
						title: '收件人',
						name: 'recipients',
						type: 'input',
						value: '',
						isShow: true,
						isSelected: true
					},
					{
						title: '收件人联系方式',
						name: 'recipients_phone',
						type: 'input',
						value: '',
						isShow: true,
						isSelected: true
					},
					{
						title: '核查状态',
						name: 'handle_status',
						type: 'select',
						optionList: [
							{label: '全部', value: ''},
							{label: '已处理', value: 0},
							{label: '待核查', value: 1},
						],
						value: '',
						isShow: true,
						isSelected: true
					},
					{
						title: '高危类型',
						name: 'person_judge_level',
						type: 'select',
						optionList: [
							{label: '全部', value: ''},
							{label: '涉毒', value: 1},
							{label: '前科', value: 2},
							{label: '极端', value: 3},
						],
						value: '',
						isShow: true,
						isSelected: true
					},
					{
						title: '收件时间',
						name: 'registration_date',
						type: 'date',
						value: [],
						isShow: true,
						isSelected: true
					},
				],
				form: {
					logistics_id: '',
					logistics_no: '',
					logistics_enterprise: '',
					company_type: '',
					arrive_region: [],
					sender: '',
					sender_phone: '',
					employee_name: '',
					recipients: '',
					recipients_phone: '',
					handle_status: '',
					registration_date: [],
					page_start: 1,
					page_size: 10,
          person_judge_level: ''
				},
				loading: false,
				tableList: [
					{
						title: '收件编号',
						width: 160,
						name: 'logistics_id',
						isShow: true,
						isSelected: true
					},
					{
						title: '收件单号',
						width: 160,
						name: 'logistics_no',
						isShow: true,
						isSelected: true
					},
					{
						title: '核查状态',
						width: 160,
						name: 'handle_status_name',
						isShow: true,
						isSelected: true
					},
					{
						title: '承运物流企业',
						width: 200,
						name: 'company_name',
						isShow: true,
						isSelected: true
					},
					// {
					// 	title: '企业类型',
					// 	width: 120,
					// 	name: 'type_desc',
					// 	isShow: true,
					// 	isSelected: true
					// },
					// {
					// 	title: '送达站点',
					// 	width: 180,
					// 	name: 'arrive_region_name',
					// 	isShow: true,
					// 	isSelected: true
					// },
					{
						title: '寄件人',
						width: 120,
						name: 'post_communicate_name',
						isShow: true,
						isSelected: true
					},
					{
						title: '寄件人联系方式',
						width: 160,
						name: 'post_communicate_mobile',
						isShow: true,
						isSelected: true
					},
					// {
					// 	title: '揽件员',
					// 	width: 120,
					// 	name: 'employee_name',
					// 	isShow: true,
					// 	isSelected: true
					// },
					{
						title: '收件人',
						width: 120,
						name: 'receive_communicate_name',
						isShow: true,
						isSelected: true
					},
					{
						title: '高危类型',
						width: 120,
						name: 'person_judge_name',
						isShow: true,
						isSelected: true
					},
					{
						title: '收件人联系方式',
						width: 160,
						name: 'receive_communicate_mobile',
						isShow: true,
						isSelected: true
					},
					{
						title: '收件时间',
						width: 200,
						name: 'create_time',
						isShow: true,
						isSelected: true
					},
					{
						title: '操作',
						width: 150,
						name: 'handler',
						fixed: 'right',
						btns: [
							{
								type: 'look',
								name: '详情'
							},
              {
                type: 'bj',
                name: '标记'
              },
						],
						isSelected: true
					}
				],
				tableData: [],
				total: 0,
				download_url: '',
        showModel: false,
        person_judge_level: '',
        logistics_id: '',
        person_name: '',
        bjList: [
          {value: 1, name: '吸毒', color: '#F56C6C'},
          {value: 2, name: '前科', color: '#E6A23C'},
          {value: 3, name: '极端', color: '#000'},
        ]
			};
		},
		computed: {
			postData() {
				let data = {
					logistics_type: 2,
					dubious_person: "1",
					logistics_id: this.form.logistics_id,
					logistics_no: this.form.logistics_no,
					logistics_enterprise: this.form.logistics_enterprise,
					company_type: this.form.company_type,
					arrive_region: this.form.arrive_region.length ? this.form.arrive_region[this.form.arrive_region.length - 1] : '',
					sender: this.form.sender,
					sender_phone: this.form.sender_phone,
					employee_name: this.form.employee_name,
					recipients: this.form.recipients,
					recipients_phone: this.form.recipients_phone,
					handle_status: this.form.handle_status,
					isprotocol: this.form.isprotocol,
					pagination: {
						page_start: this.form.page_start,
						page_size: this.form.page_size
					}
				};
        if(this.form.person_judge_level){
          data.person_judge_level = this.form.person_judge_level
        }
				if (this.form.registration_date && this.form.registration_date.length > 0) {
					data.create_time_start = this.form.registration_date[0] / 1000;
					data.create_time_end = this.form.registration_date[1] / 1000;
				}
				return data;
			},
			...mapGetters(['authority', 'getAreaList']),
			isDetail() {
				return this.authority[this.currentPath] && this.authority[this.currentPath].i;
			},
      isBj() {
        return true;
      },
		},
		watch: {},
		components: {},
		methods: {
      showBjModel(info){
        this.person_name = info.receive_communicate_name
        this.logistics_id = info.logistics_id
        this.person_judge_level = info.person_judge_level
        this.showModel = true
      },
      submitBj(){
        let bj_name = this.bjList.find(bj=> this.person_judge_level == bj.value).name
        this.$confirm(`确定将${this.person_name}标记为${bj_name}`).then(() => {
          this.$axios.post(this.$api.updJuperson, {
            logistics_id: this.logistics_id,
            person_judge_level: this.person_judge_level,
          }).then(res => {
            let {code, msg, data} = res;
            if (code == 200) {
              this.$message.success('标记成功');
              this.showModel = false;
              this.getData()
            } else {
              this.$message.error(msg);
            }
          }).catch(ret => {
            this.$message.error(ret.msg || '服务繁忙，请稍后再试');
          });
        })
      },
			setFilterData(val, nameList) {
				for (let item of this.filterData) {
					if (nameList.indexOf(item.name) !== -1) {
						item.optionList = val[item.name]
					}
				}
			},
			getRegionList() {
				if (this.getAreaList.length) {
					this.setFilterData({
						arrive_region: this.getAreaList
					}, ['arrive_region'])
				} else {
					this.$axios.post(this.$api.arriveRegionList, {}).then(res => {
						let {code, msg, data} = res;
						if (code == 200) {
							this.setFilterData({
								arrive_region: data
							}, ['arrive_region'])
							this.changeState({areaList: data})
						} else {
							this.$message.error(msg);
						}
					}).catch(ret => {
						this.$message.error(ret.msg || '服务繁忙，请稍后再试');
					});
				}
			},
			//导出
			exportExcel() {
				this.$import_excal(this.download_url || "");
			},
			sizeChange(val) {
				this.form.page_size = val;
				this.getData()
			},
			pageChange(val) {
				this.form.page_start = val;
				this.getData()
			},
			filterChange(data) {
				this.form = {...this.form, ...data};
				this.getData();
			},
			getData() {
				this.tableData = [];
				this.loading = true;
				this.$axios.post(this.$api.admin_logisticsDubious, {...this.postData}).then(res => {
					let {code, msg, data} = res;
					this.loading = false;
					if (code == 200) {
						let arr = ['物流', '快递', '分拣中心']
						this.tableData = data.list.filter(item => {
							item.company_type_str=arr[item.company_type]
							item.detail = this.isDetail || true
              item.bj = this.isBj || true
              item.receive_communicate_name_color = this.bjList.find(bj=> item.person_judge_level == bj.value)?.color || ''
							return item;
						});
						this.download_url = data.download_url || ''
						this.total = data.pagination.total_count || 0;
					} else {
						this.total = 0
						this.tableData = [];
					}
				}).catch(ret => {
					this.loading = false;
					this.$message.error(ret.msg || '服务繁忙，请稍后再试');
				});
			},
			tableClick(data, type) {
        if(type == 'bj'){
          this.showBjModel(data)
        }else{
          this.$toRoutePath({
            path: "/logistics_list/logistics_list_detail",
            edit: true,
            query: {logistics_id: data.logistics_id}
          });
        }
			},
		},
		mounted() {
			this.getRegionList();
			this.getData();
		},
		created() {
		}
	}
</script>

<style scoped lang="less" src="@/style/government/receiveInfoManage/suspiciousPersonnelReceive/index.less">

</style>
<style scoped lang="less" src="@/style/cooperate/catalog/catalogList/index.less">

</style>
